package com.tanhua.server.service;

import com.tanhua.dubbo.api.mongo.UserLocationApi;
import com.tanhua.server.interceptor.UserHolder;
import org.apache.dubbo.config.annotation.DubboReference;
import org.springframework.stereotype.Service;

import java.util.Map;

/**
 * 搜附近-地理位置上报
 */
@Service
public class BaiduService {

    @DubboReference
    private UserLocationApi userLocationApi;

    /**
     * 上报地理位置
     * @param paramMap
     * @return
     */
    public void reportLocation(Map<String, Object> paramMap) {
        // 经度
        Double longitude = (Double) paramMap.get("longitude");
        // 纬度
        Double latitude = (Double) paramMap.get("latitude");
        String address = (String)paramMap.get("addrStr");
        /*UserLocation userLocation = new UserLocation();
        userLocation.setLocation(null);
        userLocation.setxxx();*/
        //没有封装UserLocation 原因：报序列化异常
        userLocationApi.reportLocation(UserHolder.getUserId(),longitude,latitude,address);
    }
}
